package com.typy.www.tpay.base;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.typy.www.tpay.util.CrashHandler;
import com.typy.www.tpay.util.GlideUtils;
import com.typy.www.tpay.util.Logutil;
import com.typy.www.tpay.util.PopupUtil;
import com.typy.www.tpay.util.SharedPreferencesUtil;
import com.typy.www.tpay.util.ToastUtil;
import com.typy.www.tpay.volley.RequestQueueUtil;

/**
 * Created by 13799 on 2018/6/17.
 */

public class BaseApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        SharedPreferencesUtil.init(this);
        ToastUtil.init(this);
        RequestQueueUtil.init(this);
        CrashHandler.getInstance().init(this);
        initImageLoader(getApplicationContext());
        GlideUtils.init(this);
        PopupUtil.init(this);
    }
    public static void initImageLoader(Context context) {

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context).threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                .writeDebugLogs().build();
        ImageLoader.getInstance().init(config);
    }
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);
    }
}
